package com.pms.web;

import java.io.IOException;

import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.pms.entity.Contact;
import com.pms.entity.Recoder;

import com.pms.service.RecoderService;
import com.pms.util.Page;

public class RecoderServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String p=request.getParameter("p");
		int pageNum=0;
		if(p==null||"".equals(p)){
			pageNum=1;
		}else {
			try {
				pageNum=Integer.parseInt(p);
			} catch (NumberFormatException e) {
				// TODO Auto-generated catch block
				pageNum=1;
			}
			
		}
		HttpSession session=request.getSession();
		RecoderService rs=new RecoderService();
		Contact contact=(Contact)session.getAttribute("contact");
		String contactId=contact.getContactId();
		Page<Recoder> recoderList=rs.findByUserIdAndContactId(contactId,pageNum);
		session.setAttribute("recoderlist",recoderList);
		
		request.getRequestDispatcher("contact.jspx").forward(request, response);
	}
	
}
